import 'package:flutter/material.dart';
import 'package:xiongan_app_yy/widgets/comm/left_icon_widget.dart';

//预约功能入口
class SubscribeListPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return SubscribeListPageState();
  }
}

class SubscribeListPageState extends State<SubscribeListPage> {
  List imageList = [
    "assets/images/intput_appointment.png",
    "assets/images/out_appointment.png",
    "assets/images/delivery_appointment.png",
    "assets/images/return_appointment.png",
    "assets/images/return_appointment.png"
  ];
  List titleList = ["入库预约", "出库预约", "配送预约", "工程结余\n退库预约","调配预约"];
  List<Border> borderList = [
    Border(
        bottom: BorderSide(width: 1, color: Color(0xffdddddd)),
        right: BorderSide(width: 1, color: Color(0xffdddddd))),
    Border(bottom: BorderSide(width: 1, color: Color(0xffdddddd)))
  ];
  Border drawBorder;
  List routeList = [
    "/invList",
    "/outvList",
    "/delivery_list",
    "/return_booking",
     "/deployment_list"
  ];

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: new AppBar(
          leading: LeftIconWidget(icon: Icons.chevron_left, isize: 36),
          backgroundColor: Color(0XFF00A5F1),
          title: Text(
            "预约",
            style: TextStyle(fontSize: 18),
          ),
          elevation: 0,
          centerTitle: true,
        ),
        body: GridView.builder(
            itemCount: titleList.length,
            gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                crossAxisCount: 3, //横轴三个子widget
                childAspectRatio: 0.9 //宽高比为1时，子widget
                ),
            itemBuilder: (BuildContext context, int index) {
              if (index % 3 == 0) {
                drawBorder = borderList.elementAt(0);
              } else if (index % 3 == 1) {
                drawBorder = borderList.elementAt(0);
              } else if (index % 3 == 2) {
                drawBorder = borderList.elementAt(1);
              }
              ;
              return GestureDetector(
                child: Container(
                    decoration: BoxDecoration(border: drawBorder,color: Colors.white),
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: <Widget>[
                        Container(
                            padding: EdgeInsets.only(left: 38, right: 38),
                            child: Image.asset(imageList.elementAt(index),
                                fit: BoxFit.fill)),
                        Container(
                          child: Text(titleList.elementAt(index)),
                        )
                      ],
                    )),
                onTap: () {
                  Navigator.pushNamed(context, routeList.elementAt(index));
                },
              );
            })
    );
  }
}
